﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using TL_Cloud.Core.Entities;

namespace TL_Cloud.Models.BookShop
{
    public partial class Bk_Info : BaseEntity
    {
        public string BookId { get; set; }
        public string BookName { get; set; }

        public string BKTypeId { get; set; }
        public string Author { get; set; }
        public string Pulisher { get; set; }
        public string Isbn { get; set; }
        public string ConverUrl { get; set; }
        public string Introduce { get; set; }
        public int? ApproveStatus { get; set; }
        public string ApproveUserId { get; set; }
        public string ApproveRemark { get; set; }
        public DateTime? ApproveDate { get; set; }
        public int? OpenCount { get; set; }
        public int? CollectCount { get; set; }
        public int? RecommendCount { get; set; }
        public string OwnerId { get; set; }
        public string OwnerName { get; set; }
        public int? DeleteMark { get; set; }
        public int? EnabledMark { get; set; }

        public string Remark { get; set; }
        public string CreateUserId { get; set; }
        public string CreateUserName { get; set; }
        public DateTime? ModifyDate { get; set; }
        public string ModifyUserId { get; set; }
        public string ModifyUserName { get; set; }
     

      
        public override void Create(string userId, string userName)
        {
            this.BookId = Guid.NewGuid().ToString();
            this.CreateDate = DateTime.Now;
            this.CreateUserId = userId;
            this.CreateUserName = userName;
            this.EnabledMark = 1;
            this.DeleteMark = 0;
            this.OpenCount = 0;
            this.CollectCount = 0;
            this.RecommendCount = 0;
        }
        public override void Modify(string userId, string userName)
        {
            this.ModifyDate = DateTime.Now;
            this.ModifyUserId = userId;
            this.ModifyUserName = userName;
        }
        public override void Mapping(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Bk_Info>(entity =>
            {
                entity.HasKey(e => e.BookId);

                entity.ToTable("BK_Info");

                entity.Property(e => e.BookId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .ValueGeneratedNever();

                entity.Property(e => e.ApproveDate).HasColumnType("datetime");

                entity.Property(e => e.ApproveRemark).HasColumnType("text");

                entity.Property(e => e.ApproveUserId)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Author)
                    .HasMaxLength(255)
                    .IsUnicode(false);

                entity.Property(e => e.BookName)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.ConverUrl)
                    .HasMaxLength(500)
                    .IsUnicode(false);

                entity.Property(e => e.CreateDate).HasColumnType("datetime");

                entity.Property(e => e.CreateUserId)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.CreateUserName)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Introduce).HasColumnType("text");

                entity.Property(e => e.Isbn)
                    .HasColumnName("ISBN")
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.ModifyDate).HasColumnType("datetime");

                entity.Property(e => e.ModifyUserId)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.ModifyUserName)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.OwnerId)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.OwnerName)
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Pulisher)
                    .HasMaxLength(50)
                    .IsUnicode(false);
            });
        }
    }
}
